home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / dbms_mag / 9107 / embay_c / eb_edit.cpp < prev    next >
C/C++ Source or Header  |  1991-03-14  |  2KB  |  73 lines

  1. // == eb_edit.cpp === program to demonstrate edit objects for Emerald Bay
  2. //                    Copyright 1991 Wes Peterson
  3.  
  4. #include "eb_edit.h"
  5.  
  6. main()
  7. {
  8.     // initialize the C Toolkit library's data formatting system
  9.  
  10.      int check = FmtInit();
  11.     if(check < 0)    {
  12.         printf("FmtInit() failed.  %s", errormsg(check));
  13.         exit(0);
  14.         }
  15.  
  16.     // initialize the database handling system & check for engine
  17.  
  18.     check = DbInit("admin");
  19.     if(!check)    {
  20.         printf("\n  error: Emerald Bay engine not loaded.");
  21.         exit(0);
  22.         }
  23.     if(check < 0) {
  24.         printf("\n  error: %s", errormsg(check));
  25.         exit(0);
  26.         }
  27.  
  28.     // open the database
  29.  
  30.     int db = DbLogin("cedit", "");
  31.     if(db < 0)  {
  32.         printf("\n  error: %s", errormsg(db));
  33.         exit(0);
  34.         }
  35.  
  36.     table names(db, "names");   // create a table object
  37.     names.open();               // open the table
  38.  
  39.     // create field objects for each field we want to access
  40.  
  41.     field last_name(names, "last_name");
  42.     field first_name(names, "first_name");
  43.     field addr(names, "addr");
  44.     field city(names, "city");
  45.     field state(names, "state");
  46.     field zip(names, "zip");
  47.     field hourly_wage(names, "hourly_wage");
  48.     field birthdate(names, "birthdate");
  49.     field sex(names, "sex");
  50.     field phone(names, "Phone");
  51.     names.top();                // position the table to the first record
  52.     scr_form f(23, 63, 71);     // create a form, specifying the colors
  53.     f.register_table(&names);   // register our table with the form
  54.  
  55.     // use at, say, get, a la X-base, to define text & fields
  56.  
  57.     f.at(22, 16); f.say("Demo supports only PG-UP, PG-DN, ESC, CTRL-ENTER");
  58.     f.at( 6, 12); f.say("Last Name: ");  f.get(last_name);
  59.     f.at( 7, 11); f.say("First Name: "); f.get(first_name);
  60.     f.at( 8, 14); f.say("Address: ");    f.get(addr);
  61.     f.at( 9, 17); f.say("City: ");       f.get(city);  f.set_width(10);
  62.     f.at( 9, 44); f.say("State: ");      f.get(state);
  63.     f.at( 9, 55); f.say("Zip: ");        f.get(zip);
  64.     f.at(10, 12); f.say("Birthdate: ");  f.get(birthdate);
  65.     f.at(10, 46); f.say("Sex: ");        f.get(sex); 
  66.     f.at(11, 17); f.say("Wage: ");       f.get(hourly_wage);
  67.     f.at(11, 44); f.say("Phone: ");      f.get(phone);
  68.  
  69.     f.read();                   // process the form
  70.     names.close();              // close the table
  71.     DbLogout(db);               // close the database
  72. }
  73.